package net.mcreator.toolsasfood.procedures;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;

public class IronPickaxeProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		double fx = 0;
		double fy = 0;
		double fz = 0;
		double nx = 0;
		double ny = 0;
		fx = (x - entity.getPersistentData().getDouble("fx") * 3) - 3;
		fy = (y - entity.getPersistentData().getDouble("fy") * 3) - 3;
		fz = (z - entity.getPersistentData().getDouble("fz") * 3) - 3;
		nx = fx;
		ny = fy;
		if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()
				.isCorrectToolForDrops((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))))) {
			for (int index0 = 0; index0 < (int) (7); index0++) {
				for (int index1 = 0; index1 < (int) (7); index1++) {
					for (int index2 = 0; index2 < (int) (7); index2++) {
						if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()
								.isCorrectToolForDrops((world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz))))) {
							if (world instanceof Level) {
								Block.dropResources(world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz)), (Level) world,
										new BlockPos((int) fx, (int) fy, (int) fz));
								world.destroyBlock(new BlockPos((int) fx, (int) fy, (int) fz), false);
							}
						}
						fx = fx + 1;
					}
					fx = nx;
					fy = fy + 1;
				}
				fy = ny;
				fz = fz + 1;
			}
		}
		entity.getPersistentData().putBoolean("bkd", (true));
	}
}
